#include "stdafx.h"
#include "JSObj_Url.h"

CJSObj_Url::CJSObj_Url(IWebBrowser2* pWeb)
	: CScriptObject(pWeb)
	, m_lCodepage(0)
{
}

CJSObj_Url::CJSObj_Url(IWebBrowser2* pWeb, IDispatch* pDisp) 
	: CScriptObject(pWeb, pDisp)
	, m_lCodepage(0)
{
	GetAll();
}

void CJSObj_Url::GetAll()
{
	GetValue(CComBSTR(L"url"), &m_bstrUrl);
	GetValue(CComBSTR(L"header"), &m_bstrHeader);
	GetValue(CComBSTR(L"data"), &m_bstrData);
	GetValue(CComBSTR(L"refer"), &m_bstrRefer);
	GetValue(CComBSTR(L"codepage"), &m_lCodepage);

	{
		_variant_t v;
		GetValue(CComBSTR(L"session"), &v);
		if (v.vt == VT_DISPATCH)
		{
			IDispatch* p = v;
			m_pSession.Attach(p);
		}
	}
}

void CJSObj_Url::SetAll()
{
	SetValue(CComBSTR(L"url"), _variant_t(m_bstrUrl));
	SetValue(CComBSTR(L"header"), _variant_t(m_bstrHeader));
	SetValue(CComBSTR(L"data"), _variant_t(m_bstrData));
	SetValue(CComBSTR(L"refer"), _variant_t(m_bstrRefer));
	SetValue(CComBSTR(L"session"), _variant_t(m_pSession.p));
	SetValue(CComBSTR(L"codepage"), _variant_t(m_lCodepage));
}
